/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/
#include <iostream>
#include <vector>
#include <string>

int main() {
    std::string input;
    std::getline(std::cin, input);
    
    std::vector<std::string> sp;
    std::string token;
    for (char c : input) {
        if (c == ' ') {
            sp.push_back(token);
            token.clear();
        } else {
            token += c;
        }
    }
    sp.push_back(token);

    std::string st;
    for (const std::string& el : sp) {
        if (el == "zero") {
            st += "0";
        } else if (el == "one") {
            st += "1";
        } else if (el == "two") {
            st += "2";
        } else if (el == "three") {
            st += "3";
        } else if (el == "four") {
            st += "4";
        } else if (el == "five") {
            st += "5";
        } else if (el == "six") {
            st += "6";
        } else if (el == "seven") {
            st += "7";
        } else if (el == "eight") {
            st += "8";
        } else if (el == "nine") {
            st += "9";
        } else {
            std::cout << "Wrong input" << std::endl;
            break;
        }
    }

    if (st.length() == 3) {
        int n = std::stoi(st);
        int num = 0;
        bool flag = true;
        while (flag) {
            int nmin = n - num, nmax = n + num;
            for (int i = 2; i <= nmin / 2 + nmin % 2; ++i) {
                if (nmin % i == 0) {
                    break;
                }
                if (i == nmin / 2 + nmin % 2) {
                    std::cout << nmin << std::endl;
                    flag = false;
                }
            }
            for (int i = 2; i <= nmax / 2 + nmax % 2; ++i) {
                if (nmax % i == 0) {
                    break;
                }
                if (i == nmax / 2 + nmax % 2) {
                    if (flag) {
                        std::cout << nmax << std::endl;
                        flag = false;
                    }
                }
            }
            num++;
        }
    }

    return 0;
}